﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using DAO;

namespace EngineeringMaster.Student
{
    public partial class ChooseCourse : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                Session["StudentId"] = "000000";
                Session["StudentName"] = "施文";
            }
            this.lbName2.Text = Session["StudentName"].ToString();
        }

        protected void grSelectedCourse_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void grSelectedCourse_RowCommand(object sender, GridViewCommandEventArgs e)
        {

        }

        protected void LinkButton2_Click(object sender, EventArgs e)
        {
            LinkButton lkb = (LinkButton)sender;
            string studentId = Session["StudentId"].ToString();
            string courseId = lkb.CommandArgument.ToString();
           // Response.Write(courseId + " " + studentId);
           CourseDAO courseDao = new CourseDAO();
           if(courseDao.cancelCourse(studentId, courseId))
           {
             //  Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('删除成功。')</script>");
               grSelectedCourse.DataBind();
           }
           else
           {
               Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('删除失败。')</script>");
           }

        }

        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            LinkButton lkb = (LinkButton)sender;
            Response.Redirect("~/Student/SelectCourse.aspx?CourseType=" + lkb.CommandArgument.ToString().Trim());
        }
    }
}
